package Ui;


/*
 * @author Paolo Cordova
 */

public class PieceState 
{
	DisplayAssembler display = DisplayAssembler.getInstance();

	protected double xBuffer = .8;
	protected double upRightYBuffer = .5;
	protected double leftDownYBuffer = .4;

	protected void changeState(Piece piece, PieceState newState) {
		piece.changeState(newState);
	}

	protected void move(Piece piece, int currentSpace, int newSpace) {

	}

	protected int moveSquareLeft(final Piece piece, int currentX, final int currentY, double percent) {
		
		for (int i = 0; i < DisplayAssembler.getSpaceWidth() * percent; i++) {
			display.animateComponentLocation(piece.getIcon(), --currentX, currentY);
			
			try {
				Thread.sleep(1);
			} catch (Exception e) {
			}
		}
		return currentX;
	}

	protected int moveSquareRight(Piece piece, int currentX, int currentY, double percent) {
		for (int i = 0; i < DisplayAssembler.getSpaceWidth() * percent; i++) {
			display.animateComponentLocation(piece.getIcon(), ++currentX, currentY);
			
			try {
				Thread.sleep(1);
			} catch (Exception e) {
			}
		}
		return currentX;
	}

	protected int moveSquareUp(Piece piece, int currentX, int currentY, double percent) {
		for (int i = 0; i < DisplayAssembler.getSpaceWidth() * percent; i++) {
			display.animateComponentLocation(piece.getIcon(), currentX, --currentY);
			
			try {
				Thread.sleep(1);
			} catch (Exception e) {
			}
		}
		return currentY;
	}

	protected int moveSquareDown(Piece piece, int currentX, int currentY, double percent) {
		for (int i = 0; i < DisplayAssembler.getSpaceWidth() * percent; i++) {
			display.animateComponentLocation(piece.getIcon(), currentX, ++currentY);
			
			try {
				Thread.sleep(1);
			} catch (Exception e) {
			}
		}
		return currentY;
	}
}